package cn.itrip.search.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Created by Administrator on 2018/11/21.
 */

@Configuration  //自动在本类上下文加载一些环境变量信息
@EnableSwagger2 //使Swagger生效
@ComponentScan({"cn.itrip.search.controller"})//设置Swagger扫描包
public class SwaggerConfig {
        @Bean//<bean id="docket" class="Docket">
        public Docket docket(){
            return new Docket(DocumentationType.SWAGGER_2)
                    .apiInfo(ApiInfo())
                    .select()
                    .apis(RequestHandlerSelectors.any())
                    .paths(PathSelectors.any())
                    .build();

        }
        @Bean
        public ApiInfo ApiInfo(){
            return new ApiInfoBuilder()
                    .title("爱旅行-XX业务模块")
                    .termsOfServiceUrl("http://www.itrip.com/auth")
                    .contact("爱旅行项目组")
                    .version("1.0")
                    .build();
        }

}
